package com.coderman.business.service.imp;

import com.coderman.business.mapper.AdultexamMapper;
import com.coderman.business.service.IAdultexamService;
import com.coderman.business.service.base.AbstractServiceImpl;
import com.coderman.common.model.business.ClassInfo;
import com.coderman.common.model.student.Adultexam;
import com.coderman.common.vo.system.PageVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import java.util.List;


@Service
public class AdultexamServiceImpl extends AbstractServiceImpl<AdultexamMapper, Adultexam, Integer> implements IAdultexamService {
    @Autowired
    private AdultexamMapper adultexamMapper;
    @Override
    public PageVO<Adultexam> findAdultexamList(Integer pageNum, Integer pageSize, Adultexam adultexam) {
        //已经拥有的
        PageHelper.startPage(pageNum,pageSize);
        Example o = new Example(Adultexam.class);
        Integer examtype = adultexam.getExamtype();
        //Integer clsStatus = classVo.getClsstatus();
        Example.Criteria criteria = o.createCriteria();
        if(examtype!=null){
            criteria.andEqualTo("examtype",examtype);
        }

        List<Adultexam> classList= adultexamMapper.selectByParams(adultexam);
        PageInfo<Adultexam> info=new PageInfo<>(classList);
        return new PageVO<>(info.getTotal(),classList);
    }

    @Override
    public List<Adultexam> findAll() {
        return adultexamMapper.selectAll();
    }

    @Override
    public void add(Adultexam adultexam) {
        adultexamMapper.insert(adultexam);
    }

    @Override
    public Adultexam edit(Integer id) {
        return adultexamMapper.selectByPrimaryKey(id);
    }

    @Override
    public void update( Adultexam adultexam) {
        adultexamMapper.updateByPrimaryKey(adultexam);
    }
}
